home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / uobj.com / TEST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-01-08  |  938 b   |  53 lines

  1. program TestClone;
  2.  
  3.   uses CRT,Objects,UObj;
  4.  
  5.   type
  6.     pAncestor = ^Ancestor;
  7.     Ancestor = object(TObj)
  8.       procedure   WhoAmI;                   virtual;
  9.       end;
  10.  
  11.     procedure   Ancestor.WhoAmI;
  12.       begin
  13.         Writeln('Ancestor');
  14.       end;
  15.  
  16.   type
  17.     pChild = ^Child;
  18.     Child = object(Ancestor)
  19.       procedure   WhoAmI;                   virtual;
  20.       end;
  21.  
  22.     procedure   Child.WhoAmI;
  23.       begin
  24.         Writeln('Child');
  25.       end;
  26.  
  27.   var
  28.     theAncestor : pAncestor;
  29.     theChild : pChild;
  30.     theClone : pAncestor;
  31.  
  32.   begin
  33.     ClrScr;
  34.  
  35.     New(theAncestor,Bind);
  36.     New(theChild,Bind);
  37.  
  38.     theClone := theChild^.Clone;
  39.     theChild^.WhoAmI;
  40.     theClone^.WhoAmI;
  41.     theClone^.Free;
  42.  
  43.     writeln;
  44.  
  45.     theClone := theAncestor^.Clone;
  46.     theAncestor^.WhoAmI;
  47.     theClone^.WhoAmI;
  48.     theClone^.Free;
  49.  
  50.     theAncestor^.Free;
  51.     theChild^.Free;
  52.   end.
  53.